package DB;


import java.sql.*;

public class DBConnection {
	
	private static Connection con;
	
	
	/*
	 * Retorna conexao
	 */
	public static Connection getConnection() {
		if( con != null ) 
			return con;

		
		try {
			Class.forName("com.mysql.jdbc.Driver");
			con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/PF1","root","");
			
		} catch (Exception e) {
			e.printStackTrace();
		}
			
		return con;
	}
	
	/*
	 * Fecha conexao
	 */
	public static void close() {
		try {
			con.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
